<?php
class Solution {

    /**
     * @param Integer[] $nums
     * @return Integer
     */
    function removeDuplicates(&$nums) {
        $len = count($nums);
        $i = 0; $j = 1;
        while ($j< $len){
            if($nums[$j] != $nums[$i]){
                $nums[++$i] = $nums[$j];
            }
            $j++;
        }
        return $i+1;
    }
}

